#include <stdio.h>
#include <time.h>
#include <errno.h>
#include <string>

#include  "DiskSector.cpp"
#include  "FileRestore.cpp"
#include  "Shell.cpp"

using namespace std;
DiskSector *ds;
FileRestore *ns;

int main(int argc, char* argv[]) {
    const char *dev = "/data/log/3g.sc";
    map <string,string> params;
//    params["-i"]="fir";
    params["-i"]="r";
    if(argc >1) dev=argv[1];
    for(int i=2;i<argc;i+=2) {
        params[argv[i]]=argv[i+1];
    }
    
    try{
        ds=new DiskSector(dev);
        ns=new FileRestore();
//        ns->nfs->setJumpM(4);

        if(params.count("-j")>0) 
            ns->nfs->setJumpM(atoi(params["-j"].c_str()));
        
        if(params.count("-d")>0) 
            ns->toDir=params["-d"];
        
        Shell *s=new Shell();
        s->init(params["-i"]);
        s->run();
    }catch(Exception *e) {
        puts(e->msg);
    }
//    catch(...) {
//        cout << "ERR:" << errno <<endl;
//    }
    return (0);
}
